angular.module('Controller')
.controller 'ProductInfoDetailCtrl', ($scope, $state, menuManage, commonUtil, userData, $localStorage, commonConstant, wfAlert, $http) ->
    console.log "ProductInfoDetailCtrl"
    $scope.$storage = $localStorage
    $scope.currentId=$state.params.childId
    $scope.subMenus= [
        {
            name: "无源元件"
            type: "subPage"
            enName: "Compenent"
            route: "product-info"
            id: 1
        }
        {
            name: "有源元件"
            type: "subPage"
            enName: "IC"
            route: "product-info"
            id: 2
        }
        {
            name: "元件盒/样品盒"
            type: "subPage"
            enName: "Box/Sample Kit"
            route: "product-info"
            id: 3
        }
        {
            name: "工具"
            type: "subPage"
            enName: "Tools"
            route: "product-info"
            id: 4
        }
        {
            name: "软件"
            type: "subPage"
            enName: "Software"
            route: "product-info"
            id: 5
        }
        {
            name: "行业规范"
            type: "subPage"
            enName: "Rules"
            route: "product-info"
            id: 6
        }
        {
            name: "其他"
            type: "subPage"
            enName: "Others"
            route: "product-info"
            id: 7
        }
    ]
    console.log $localStorage.currentNews
    $scope.clickSubMenu=(id)->
        $state.go('product-info',{childId:id})
    $('html, body').animate({
        scrollTop: $("#header").offset().top
    }, 100);
    $http.put("/wainNews/#{$localStorage.currentNews.id}")
    dynamicNavWid=()->
        wordWid=0
        _.each $('.nav-item-tag'),(tagElem)->
            wordWid+=tagElem.scrollWidth
        navWid=$('.public-pc-nav').parent().css('width').replace('px','')
        sumWid=parseInt(navWid)-32
        marginWid=((sumWid-wordWid)/($('.nav-item-tag').length-1)).toFixed(4)
        marginWid=8 if marginWid<8
        $(".nav-item-tag").css('margin-right',marginWid+'px')
    _.defer(()->
        dynamicNavWid()
    )


